<div class="dux-page-header uk-clearfix">
    <div class="page-title">
        <a class="uk-button uk-button-primary" href="{url('index')}"> 返回列表</a>
    </div>
    <div class="page-action">
        <a class="uk-button uk-button-danger" href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
    </div>
</div>

<div class="uk-margin-top">
    <div class="uk-card uk-card-default uk-card-small dux-panel">
        <div class="uk-card-header">{$assignName}优惠券</div>
        <div class="uk-card-body">
            <form class="dux-form uk-form   uk-form-horizontal " data-dux="form-bind" method="post">
                <fieldset>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">类型</label>
                        <div class="uk-form-controls">
                            <select name="type" id="type" class="uk-form-field" required>
                                <option value="common">全品优惠券</option>
                                <!--loop{$typeList as $type => $vo}-->
                                <option value="{$type}">{$vo.name}优惠券</option>
                                <!--{/loop}-->
                            </select>
                        </div>
                    </div>
                    <div class="uk-form-group" style="display: none" id="special">
                        <label class=" uk-form-label">指定ID</label>
                        <div class="uk-form-controls">
                            <input type="number" name="has_id" value="{$info.has_id}" placeholder="指定编号，如商品ID" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">优惠券金额</label>
                        <div class="uk-form-controls">
                            <input type="text" name="money" value="{$info.money}" placeholder="请输入优惠券金额" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">满减金额</label>
                        <div class="uk-form-controls">
                            <input type="text" name="meet_money" value="{$info.meet_money ? $info.meet_money : 0}" placeholder="满足使用金额条件" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">发放时间</label>
                        <div class="uk-form-controls">
                            <input type="text" data-dux="form-date" name="start_time" data-type="datetime" value="{$info.start_time ? date('Y-m-d H:i:s', $info.start_time) : date('Y-m-d H:i:s')}" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">结束时间</label>
                        <div class="uk-form-controls">
                            <input type="text" data-dux="form-date" name="end_time" data-type="datetime" value="{$info.end_time ? date('Y-m-d H:i:s', $info.end_time) : date('Y-m-d H:i:s')}" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">库存数量</label>
                        <div class="uk-form-controls">
                            <input type="text" name="stock" value="{$info.stock ? $info.stock : 100}" placeholder="" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">有效天数</label>
                        <div class="uk-form-controls">
                            <input type="number" name="expiry_day" value="{$info.expiry_day ? $info.expiry_day : 10}" placeholder="" required>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">兑换方式</label>
                        <div class="uk-form-controls">
                            <select name="exchange_type" id="exchange_type" class="uk-form-field" required>
                                <!--loop{$currencyList as $type => $vo}-->
                                <option value="{$type}" {$vo.exchange_type == $type ? 'selected' : ''}>{$vo.name}</option>
                                <!--{/loop}-->
                            </select>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">兑换价格</label>
                        <div class="uk-form-controls">
                            <input type="text" name="exchange_price" value="{$info.exchange_price ? $info.exchange_price : 0}" placeholder="" required>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">状态</label>
                        <div class="uk-form-controls uk-form-controls-text">
                            <?php $info['status'] = isset($info['status']) ? $info['status'] : 1;  ?><div class="uk-grid">
                            <label>
                                <!--if{$info['status']}-->
                                <input name="status" value="1" checked="checked" type="radio">
                                <!--{else}-->
                                <input name="status" value="1" type="radio">
                                <!--{/if}-->
                                上架
                            </label>
                            <label>
                                <!--if{!$info['status']}-->
                                <input name="status" checked="checked" value="0" type="radio">
                                <!--{else}-->
                                <input name="status" value="0" type="radio">
                                <!--{/if}-->
                                下架
                            </label>
                        </div></div>
                    </div>

                    <div class="uk-form-group">
                        <div class="uk-form-controls">
                            <input type="hidden" name="coupon_id" value="{$info.coupon_id}">
                            <button class="uk-button uk-button-primary" type="submit" disabled>保存</button>
                        </div>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>
<script>
    Do('base', function () {
        $('#type').change(function () {
            var type = $(this).val();
            if(type !== 'common') {
                $('#special').show();
            }else {
                $('#special').hide();
            }
        });
    });
</script>